/**
 * 
 */
package uk.ac.manchester.cs.graph.io;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Pavel Klinov
 *
 */
public class DOTTokenStream implements TokenStream {

	private BufferedReader m_reader = null;
	private Pattern m_delRestPattern = Pattern.compile("\\[.*\\];");
	
	
	DOTTokenStream(Reader reader) {
		
		m_reader = new BufferedReader(reader);
	}
	
	/* 
	 */
	@Override
	public String nextToken() throws IOException {

		String line = m_reader.readLine();
		
		if (line == null) return null;
		
		Matcher matcher = m_delRestPattern.matcher(line);
		
		line = matcher.replaceAll("");
		
		return line;
	}
}
